package com.heima.article.feign;

import com.heima.apis.article.IArticleClient;
import com.heima.article.service.ApArticleService;
import com.heima.model.article.dtos.ArticleDto;
import com.heima.model.common.dtos.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.mapstruct.Named;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;


//@Named("articleClient")
//@Primary
//@Bean(name = "customUserService")
@Slf4j
@RestController
public class ArticleClient implements IArticleClient {

    //当然要能够调用了service，做好本质工作，然后实现feign给远程调用，
    //这个用法是controller+feign，不同于单纯的feign，


    @Autowired
    private ApArticleService apArticleService;

    //不走controller，直接调用service？
    @PostMapping("/api/v1/article/save")
    @Override
    public ResponseResult saveArticle(@RequestBody ArticleDto dto) {
        log.info("自动注入articleClient，远程调用saveArticle");
        return apArticleService.saveArticle(dto);
    }
}
